<?php
namespace app\components\story\models;
use Yii;
use yii\base\Model;

/**
 * Created by PhpStorm.
 * User: ulric
 * Date: 2016/10/24
 * Time: 14:23
 *
 * @property string $play;
 */
class StoryForm extends Model
{
    public $story = [];

    protected $_play = "hello";

    /**
     * @return string
     */
    public function getPlay()
    {
        return $this->_play = $this->run();
    }



    public function run()
    {
        $str = "";
        foreach ($this->story as $actor) {
            $classname = $actor['class'];
            unset($actor['class']);
            $model = new $classname($actor);
            $str .= $model->go();
        }
        return $str;
    }

    public function rules()
    {
       return [[['story'],'safe']];
    }
//
//    public function attributeLabels()
//    {
//        return array_merge(parent::attributeLabels(),[
//            'story' => '故事'
//        ]);
//    }
}